#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
日志类，通过读取配置文件，定义日志级别、日志文件名、日志格式等。
'''

import logging.config
from config import Config
from HTMLTestRunner_PY3 import HTMLTestRunner


class Logger(object):   
    def __init__(self,ModuleName='ZYTest'):
        self.logger =logging.getLogger(ModuleName)
        
    def get_logger(self):
        logging.config.dictConfig(Config().log())
        return self.logger

class MyFilter(logging.Filter):
    def __init__(self, param=None,level=logging.INFO):
        self.param = param
        self.level = level

    def filter(self, record):
        if self.param is None:
            allow = True
        else:
            allow = self.param not in record.msg
        if record.levelno == self.level:
            record.msg = 'changed: ' + record.msg
            return allow

logger = Logger().get_logger()

'''
logger.debug('debug message')
logger.info('info message')
logger.warn('warn message')
logger.error('error message')
logger.critical('critical message')
'''       